<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ .title }}</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
    <div id="test">
        <input type="checkbox" v-model="base64"> 是否解码 : [[ base64 ]]
        <label >查询到结果: [[ items.length ]] 条 </label>
        <label> 数据库表名：{{ .tableName }}</label>
        <label> 错误信息：{{ .Error }}</label>
        <table border="solid">
            <tr bgcolor="gray">
                <th>Dataid</th>
                <th>Index1</th>
                <th>Index2</th>
                <th>Type</th>
                <th>Version</th>
                <th>Buffer</th>
                <th>Createtime</th>
                <th>Updatetime</th>
            </tr>
            <tr v-for="item in items">
                <td bgcolor="#f0f8ff">[[ item.Dataid ]]</td>
                <td bgcolor="#faebd7">[[ item.Index1 ]]</td>
                <td bgcolor="#f5f5dc">[[ item.Index2 ]]</td>
                <td bgcolor="#ffe4c4">[[ item.Type ]]</td>
                <td bgcolor="#ffebcd">[[ item.Version ]]</td>
                <td v-if="base64">[[ atob(item.Buffer) ]]</td>
                <td v-else>[[ item.Buffer ]]</td>
                <td bgcolor="#7fffd4">[[ GetDate(item.Createtime*1000) ]]</td>
                <td bgcolor="aqua">[[ GetDate(item.Updatetime*1000) ]]</td>
            </tr>
        </table>
    </div>
</body>
<script type="text/javascript">
    var p = new Vue({
        el : "#test",
        delimiters: ['[[',']]'], //防止与模板冲突
        data : {
            items:{{ .p1 }},
            base64: true,
        },
        methods:{
        }
    });
    function GetDate(date){
        let dt = new Date(date);
        let year = dt.getFullYear();
        let MM = dt.getMonth()+1;       MM = MM > 9 ? MM : "0" + MM ;
        let dd = dt.getDate();          dd = dd > 9 ? dd : "0" + dd ;
        let hh = dt.getHours();         hh = hh > 9 ? hh : "0" + hh ;
        let mm = dt.getMonth();         mm = mm > 9 ? mm : "0" + mm ;
        let ss = dt.getSeconds();       ss = ss > 9 ? ss : "0" + ss ;
        return year + "." + MM + "." + dd + " " + hh + ":" + mm + ":" + ss
    }
</script>
</html>
